layui.use(['element', 'tree', 'zlContext', 'zlConfig'], function (exports) {
    var $ = layui.$,
        zlContext = layui.zlContext,
        layer = layui.layer,
        zlConfig = layui.zlConfig,
        statusName = zlConfig.global.result.statusName,
        msgName = zlConfig.global.result.msgName,
        OK = zlConfig.global.result.okState,
        form = layui.form;  

    function getdata() {
        zlContext.post(layui.cache['contentPath'] + "/manager/coreproject/queryshow", {}, function (data) {
            if (data[statusName] == OK) {
                var datalist = data['obj'];
                for (var i = 0; i < datalist.length; i++) {
                    var curdata = datalist[i];
                    var html = [
                        '<div class="layui-col-md2">'
                        , '    <div class="context">'
                        , '        <img class="new" icon="' + curdata.ICON_SMALL + '" resaction="' + curdata.RES_ACTION + '" rwid="' + curdata.RWID + '"src="' + layui.cache['contentPath'] + curdata.ICON_SMALL_URL + '" alt="添加">'
                        , '        <p class="title">' + curdata.OBJNAME + '</p>'
                        , '    </div>'
                        , '</div>'
                    ]
                    $('.layui-row').append(html.join(''));
                }
                var loginhtml = [
                    '<div class="layui-col-md2">'
                    , '    <div class="context">'
                    , '        <img class="new" resaction="'+layui.cache['contentPath']+'/logout/" src="' + layui.cache['contentPath'] + '/static/image/login.png" alt="添加">'
                    , '        <p class="title">返回登录页面</p>'
                    , '    </div>'
                    , '</div>'
                ]
                $('.layui-row').append(loginhtml.join(''));
                setclickevent();
            }
            else {
                zlContext.errorMsg(data[msgName]);
            }
        })
    }
    getdata();
    function setclickevent() {
        $('.new').on('click', function () {
            var url = $(this).attr('resaction');
            url = getTokenIdUrl(url);
            var user = zlContext.getCurrentUser();
            // url = url+"&orgcode"++"&zhanghm="+user.userCursor.ZHANGHM+"&psw="+user.userCursor.PSW;
            var html = ["<form id='summit' method='post' action='"+url+"'>,"
            ,"<input type='hidden' name = 'orgcode' value='"+user.currentOrgCode+"'>"
            ,"<input type='hidden' name = 'zhanghm' value='"+user.userCursor.ZHANGHM+"'>"
            ,"<input type='hidden' name = 'psw' value='"+user.userCursor.PSW+"'>"
            ,"</form>"];
            $("body").append(html.join(''));
            $("#summit").submit();
        });

        $('.title').on('click', function () {
            $('.new').trigger('click');
        });
    }


    $(window).on('resize', function () {
        zlContext.setMaxHeihgt(0);
    }).resize();


});
